package Common;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class mGraphics {
	public Graphics g;
	public static int zoomLevel = 1;
	public static final int HCENTER = 1;
	public static final int VCENTER = 2;
	public static final int LEFT = 4;
	public static final int RIGHT = 8;
	public static final int TOP = 16;
	public static final int BOTTOM = 32;
	public static final int BASELINE = 64;
	public static final int SOLID = 0;
	public static final int DOTTED = 1;

	public mGraphics(Graphics g) {
		this.g = g;
	}

	public mGraphics() {
	}

	public void drawImage(Image arg0, int x, int y, int arg3) {

		x *= zoomLevel;
		y *= zoomLevel;
		g.drawImage(arg0, x, y, arg3);
	}

	public void drawLine(int x1, int y1, int x2, int y2) {

		x1 *= zoomLevel;
		y1 *= zoomLevel;
		x2 *= zoomLevel;
		y2 *= zoomLevel;
		g.drawLine(x1, y1, x2, y2);
	}

	public void drawRect(int x, int y, int w, int h) {

		x *= zoomLevel;
		y *= zoomLevel;
		w *= zoomLevel;
		h *= zoomLevel;
		g.drawRect(x, y, w, h);
	}

	public void drawRegion(Image arg0, int x0, int y0, int w0, int h0, int arg5, int x, int y, int arg8) {

		x *= zoomLevel;
		y *= zoomLevel;
		x0 *= zoomLevel;
		y0 *= zoomLevel;
		w0 *= zoomLevel;
		h0 *= zoomLevel;
		g.drawRegion(arg0, x0, y0, w0, h0, arg5, x, y, arg8);
	}

	public void drawRoundRect(int x, int y, int w, int h, int a, int b) {

		x *= zoomLevel;
		y *= zoomLevel;
		w *= zoomLevel;
		h *= zoomLevel;
		a *= zoomLevel;
		b *= zoomLevel;
		g.drawRoundRect(x, y, w, h, a, b);
	}

	public void drawString(String arg0, int x, int y, int arg3) {
		x *= zoomLevel;
		y *= zoomLevel;
		g.drawString(arg0, x, y, arg3);
	}

	public void fillRect(int x, int y, int w, int h) {
		x *= zoomLevel;
		y *= zoomLevel;
		w *= zoomLevel;
		h *= zoomLevel;
		g.fillRect(x, y, w, h);
	}

	public void fillRoundRect(int x, int y, int w, int h, int a, int b) {
		x *= zoomLevel;
		y *= zoomLevel;
		w *= zoomLevel;
		h *= zoomLevel;
		a *= zoomLevel;
		b *= zoomLevel;
		g.fillRoundRect(x, y, w, h, a, b);
	}

	public int getTranslateX() {

		return g.getTranslateX()/zoomLevel;
	}

	public int getTranslateY() {

		return g.getTranslateY()/zoomLevel;
	}

	public void setClip(int x, int y, int w, int h) {
		x *= zoomLevel;
		y *= zoomLevel;
		w *= zoomLevel;
		h *= zoomLevel;
		g.setClip(x, y, w, h);
	}

	public void setColor(int RGB) {

		g.setColor(RGB);
	}

	public void translate(int x, int y) {
		x *= zoomLevel;
		y *= zoomLevel;
		g.translate(x, y);
	}

	public static int getImageWidth(Image image) {
		return image.getWidth()/zoomLevel;
	}
	public static int getImageHeight(Image image) {
		return image.getHeight()/zoomLevel;
	}
	public void drawRGB(int[] data, int i, int width, int x, int y, int width2,
			   int height, boolean b, boolean isClip) {
			  x *= zoomLevel;
			  y *= zoomLevel;
			  width2 *= zoomLevel;
			  height *= zoomLevel;
			  width *= zoomLevel;
			  // TODO Auto-generated method stub
			  g.drawRGB(data, i, width, x, y, width2, height, b);
			 }

}
